{// 引入标签库 }
<tagLib name="html" />
<include file="Public:header" />
<load href='__TMPL__Common/style/weebox.css' />
<load href='__TMPL__Common/css/bootstrap.min.css' />
<load href='__TMPL__Common/css/fileinput.min.css' />
<div class="main">
<div class="main_title">{%ADD} <a href="{:u("EduClass/index", array("group_id"=>$group_id))}" class="back_list">{%BACK_LIST}</a></div>
<div class="blank5"></div>
<form name="edit" action="__APP__" method="post" enctype="multipart/form-data">
<table class="form" cellpadding=0 cellspacing=0>
	<tr>
		<td colspan=2 class="topTd"></td>
	</tr>
	<tr>
		<td class="item_title">标题:</td>
		<td class="item_input"><input type="text" name="title" /></td>
	</tr>
	<tr>
		<td class="item_title">目录:</td>
		<td class="item_input">
			<select name="group_id">
				<foreach name="group_list" item="group">
					<option value="{$group.id}" <if condition="$group_id eq $group['id']">selected="selected"</if>>{$group.title}</option>
				</foreach>
			</select>
		</td>
	</tr>
	<if condition="$show_price">
	<tr>
		<td class="item_title">价格:</td>
		<td class="item_input"><input type="text" name="price" /></td>
	</tr>
	</if>
	<tr>
		<td class="item_title">课时类型:</td>
		<td class="item_input">
			<select name="type">
				<option value="0">视频</option>
				<option value="1">音频</option>
			</select>
		</td>
	</tr>
	<tr id="video">
		<td class="item_title">上传视频:</td>
		<td class="item_input">
			<input type="text" name="file_id" id="file_id" />
			<input type="button" class="button" id="btn_upload" value="上传视频" />
			<span id="result"></span>
		</td>
	</tr>
	<tr id="music" style="display: none;">
		<td class="item_title">上传音频:</td>
		<td class="item_input">
            <div class="row">
                <div class="col-md-6">
                    <div id="errorBlock" class="help-block">
                    </div>
                    <input type="file" class="file" id="test-upload" accept="audio/mpeg"/>
                </div>
				<span class="tip_span" id="tip_span">请上传 mp3 格式音频</span>
            </div>
            <input type="hidden" name="play_url" id="play_url" value="{$vo.play_url}"/>
		</td>
	</tr>
	<tr>
		<td class="item_title">曲谱:</td>
		<td class="item_input"><html:imgUpload name='musicofasong' id='musicofasong' /></td>
	</tr>
	<tr>
		<td class="item_title">时长:</td>
		<td class="item_input"><input type="text" name="long_time" />分钟</td>
	</tr>
	<tr>
		<td class="item_title"></td>
		<td class="item_input">
			<!--隐藏元素-->
			<input type="hidden" name="{:conf("VAR_MODULE")}" value="EduClass" />
			<input type="hidden" name="{:conf("VAR_ACTION")}" value="insert" />
			<input type="hidden" name="course_id" value="{$course_id}" />
			<input type="hidden" id="secret_id" value="{$secret_id}" />
			<input type="hidden" id="after_sha_start_upload" value="1" />
			<!--隐藏元素-->
			<input type="submit" class="button" value="{%ADD}" />
			<input type="reset" class="button" value="{%RESET}" />
		</td>
	</tr>
	<tr>
		<td colspan=2 class="bottomTd"></td>
	</tr>
</table>	 
</form>
</div>
<script src="//qzonestyle.gtimg.cn/open/qcloud/js/vod/sdk/uploaderh5.js" charset="utf-8"></script>
<load href='__TMPL__Common/js/user_live.js' />
<load href='__TMPL__Common/js/jquery.weebox.js' />
<load href='__TMPL__Common/js/fileinput.min.js' />
<load href='__TMPL__Common/js/locales/zh.js' />
<script>
    $('select[name=type]').change(function(){
        if(this.value == 0) {
            $('#video').show();
            $('#music').hide();
        } else {
            $('#video').hide();
            $('#music').show();
        }
	});

    $("#test-upload").fileinput({
        uploadUrl: "{:u('PublicFile/do_upload',array('dir'=>'media'))}",
        language: 'zh',
        showPreview: false,
        maxFileSize: parseInt('{$max_size}'),
        allowedFileTypes: ['audio'],
        elErrorContainer: '#errorBlock'
    }).on('fileuploaded', function(event, data) {
        if (data.response.fullname) {
            $('#play_url').val(data.response.fullname);
        } else {
            $('#errorBlock').html(data.response.message).show();
        }
    });
</script>
<include file="Public:footer" />